package org.tamal.spring;

import java.math.BigDecimal;
import java.util.List;


/**
 * This is the service or business interface.
 * @author Tamal Kanti Nath
 */
public interface Service {

    /**
     * Returns an entity from JPQL query with positional parameters.
     * @param <T> the Entity type
     * @param query the named JPQL query
     * @param cls the result class type
     * @param params the positional parameter values
     * @return an entity
     */
    <T> T findEntity(String query, Class<T> cls, Object... params);

    /**
     * Returns an entity from JPQL query with named parameters.
     * @param <T> the Entity type
     * @param query the named JPQL query
     * @param cls the result class type
     * @param params the positional parameter values
     * @return a list of entities
     */
    <T> List<T> findEntities(String query, Class<T> cls, Object... params);

    /**
     * Returns an entity from HQL query with positional parameters.
     * @param <T> the Entity type
     * @param query the named HQL query
     * @param params the positional parameter values
     * @return an entity
     */
    <T> T findEntity(String query, Object... params);

    /**
     * Returns an entity from HQL query with named parameters.
     * @param <T> the Entity type
     * @param query the named JPQL query
     * @param params the positional parameter values
     * @return a list of entities
     */
    <T> List<T> findEntities(String query, Object... params);

    /**
     * This service will update address for the customer.
     * @param pan the Permanent Account Number
     * @param address the new address
     * @return number of records updated
     */
    int updateCustomerAddress(String pan, String address);

    /**
     * This service will update address for the customer.
     * @param source the account from which amount to be transferred
     * @param target the account to which amount to be transferred
     * @param amount the amount to be transferred
     */
    void transferFund(Long source, Long target, BigDecimal amount);
}
